home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / mj91 / ImageClass / usemyic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-12  |  3.6 KB  |  112 lines

  1. /*
  2.  * usemyic.c Copyright (C) 1991 Commodore-Amiga, Inc. All Rights Reserved Worldwide
  3.  * The information contained herein is subject to change without notice,
  4.  * and is provided "as is" without warranty of any kind, either expressed
  5.  * or implied.  The entire risk as to the use of this information is
  6.  * assumed by the user.
  7.  * 
  8.  * Compiled with SAS/C 5.10a LC -cfist -ms -v (must be linked with 
  9.  * mytextlabelclass.o, classface.o and hookface.o)
  10.  * 
  11.  * Written by David N. Junod
  12.  */
  13.  
  14. #include <exec/types.h>
  15. #include <exec/libraries.h>
  16. #include <intuition/intuition.h>
  17. #include <intuition/classes.h>
  18. #include <intuition/classusr.h>
  19. #include <intuition/cghooks.h>
  20. #include <intuition/gadgetclass.h>
  21. #include <intuition/imageclass.h>
  22. #include <graphics/gfx.h>
  23. #include <graphics/gfxmacros.h>
  24. #include <libraries/gadtools.h>
  25. #include <utility/tagitem.h>
  26. #include <clib/macros.h>
  27. #include <clib/exec_protos.h>
  28. #include <clib/dos_protos.h>
  29. #include <clib/intuition_protos.h>
  30. #include <clib/graphics_protos.h>
  31. #include <clib/utility_protos.h>
  32. #include <string.h>
  33.  
  34. extern struct Library *SysBase, *DOSBase;
  35. struct Library *IntuitionBase, *GfxBase, *UtilityBase;
  36.  
  37. Class          *initmyTextLabelClass(VOID);
  38. ULONG           freemyTextLabelClass(Class * cl);
  39.  
  40. VOID
  41. main(VOID)
  42. {
  43.     Class          *cl;
  44.     struct Image   *im;
  45.     struct Window  *win;
  46.     struct RastPort *rp;
  47.     UWORD           top, left, height;
  48.  
  49.     /* Make sure we're at least using Version 2.0 */
  50.     if (IntuitionBase = OpenLibrary("intuition.library", 36))
  51.     {
  52.         GfxBase = OpenLibrary("graphics.library", 36);
  53.         UtilityBase = OpenLibrary("utility.library", 36);
  54.  
  55.         /* Open a window, without system gadgets or IDCMP events */
  56.         if (win = OpenWindowTags(NULL,
  57.                                  WA_Left, 10,
  58.                                  WA_Top, 10,
  59.                                  WA_Width, 320,
  60.                                  WA_Height, 100,
  61.                                  TAG_DONE))
  62.         {
  63.             /* Cache the pointer to the RastPort */
  64.             rp = win->RPort;
  65.  
  66.             /* Cache the upper-left coordinates of the window */
  67.             top = win->BorderTop + INTERHEIGHT;
  68.             left = win->BorderRight + INTERWIDTH;
  69.  
  70.             /* Cache the height of the font */
  71.             height = rp->TxHeight + INTERHEIGHT;
  72.  
  73.             /* Initialize the custom image class. */
  74.             if (cl = initmyTextLabelClass())
  75.             {
  76.                 /* Create a new image structure, using the given string. */
  77.                 if (im = NewObject(cl, NULL,
  78.                                    IA_Data, (ULONG) "Line _1",
  79.                                    TAG_DONE))
  80.                 {
  81.                     /* Paint using the provided text string. */
  82.                     DrawImageState(rp, im, left, top,
  83.                                    IDS_NORMAL, NULL);
  84.  
  85.                     /* Replace the text string, and paint it. */
  86.                     im->ImageData = (USHORT *) "Line _2";
  87.                     DrawImageState(rp, im, left, top + height,
  88.                                    IDS_NORMAL, NULL);
  89.  
  90.                     /* Replace the text string, and paint it. */
  91.                     im->ImageData = (USHORT *) "Line _3";
  92.                     DrawImageState(rp, im, left, top + (height * 2),
  93.                                    IDS_NORMAL, NULL);
  94.  
  95.                     /* Free the image. */
  96.                     DisposeObject(im);
  97.                 }
  98.  
  99.                 /* Free the image class. */
  100.                 freemyTextLabelClass(cl);
  101.             }
  102.  
  103.             Delay(250);
  104.             CloseWindow(win);
  105.         }
  106.  
  107.         CloseLibrary(UtilityBase);
  108.         CloseLibrary(GfxBase);
  109.         CloseLibrary(IntuitionBase);
  110.     }
  111. }
  112.